import random

from   common.read_yaml  import Read_yamlData


class  DebugTalk:
    def  __init__(self):
        self.read=Read_yamlData()

    def  get_extract_order_data(self,data,randoms):
        if  randoms    not  in (0,-1,-2):
            return    data[randoms-1]

    def  get_extract_data(self,nodename,randoms=None):
        data=self.read.get_yaml_data(nodename)
        if  randoms is  not None:
             irandoms=int(randoms)
             if  irandoms==0:
                 data_value=random.choice(data)
                 data=data_value
             elif irandoms==-1:
                 data_value=','.join(data)
                 data=data_value
             elif  irandoms==-2:
                 data_value=','.join(data).split(',')
                 data=data_value
             else:
                  data=self.get_extract_order_data(data,randoms)

        return data
    def  md5_params(self,params):
        return  'ABCDEFG123456'+str(params)

if __name__=='__main__':
    F=DebugTalk()
    C=F.get_extract_data('product_id',1)
    print(C)
    print(type(C))